<template>
	<view>
		<custom title="实名认证" mode="2" fixed="fixed"></custom>
		<!-- <view class="maked-word flex flex-y-c">
			<image src="../../static/my/truename1.png" style="hight:60rpx;width:60rpx;" mode="widthFix"></image>
			<view class="text fs-26">
				相关法律法规要求，请完成实名认证！
			</view>
		</view> -->
		<view style="margin: 35rpx;">
			<view class="fs-24 color-999999">
				根据国家的相关法律法规规定以及确保账号的真实性和安全性，
				需进行本人实名认证，以获得提现等操作权限。证件信息绑定
				后将不能修改，请如实填写
			</view>
			<view class="">
				<view class="fs-28 color-333333 blod" style="margin-top: 78rpx;">
					真实姓名
				</view>
				<view class="fs-28 color-333333" style="padding: 27rpx 0; border-bottom: 2rpx solid #E6E6E6;">
					<text v-if="user_info.fullName">{{user_info.fullName}}</text>
					<input v-else type="text" v-model="card_name" placeholder="请输入您的真实姓名"
						placeholder-class="color-999999 fs-32">
				</view>
				<view class="fs-28 color-333333 blod" style="margin-top: 63rpx;">
					身份证号
				</view>
				<view class="" style="padding: 27rpx 0; border-bottom: 2rpx solid #E6E6E6;">
					<text v-if="user_info.idCard">{{user_info.idCard}}</text>
					<input v-else type="text" v-model="card_id" placeholder="请输入您的身份证号"
						placeholder-class="color-999999 fs-32">
				</view>
				<!-- <view v-if="!user_info.idCard" class="">
					<view class="fs-28 color-333333 blod" style="margin-top: 63rpx;">
						手机号
					</view>
					<view class="" style="padding: 27rpx 0; border-bottom: 2rpx solid #E6E6E6;">
						<input type="text" v-model="phoneNum" placeholder="请输入您的手机号"
							placeholder-class="color-999999 fs-32">
					</view>
					<view class="fs-28 color-333333 blod" style="margin-top: 63rpx;">
						验证码
					</view>
					<view class="flex flex-x-b " style="padding: 27rpx 0; border-bottom: 2rpx solid #E6E6E6;">
						<input type="text" v-model="code" placeholder="请输入验证码" placeholder-class="color-999999 fs-32">
						<view @click="sendRegistCode" class="">
							{{ time }}
						</view>
					</view>
				</view> -->

				<!-- <setting-item text="姓名" :hiddenIcon="true" class="mt-20">
					<text slot="right">{{user_info.fullName}}</text>
				</setting-item>
				<setting-item text="身份证号" :hiddenIcon="true">
					<text slot="right">{{user_info.idCard}}</text>
				</setting-item> -->
			</view>

			<!-- <true-name-dialog ref="fixRef" @close="close"></true-name-dialog> -->
		</view>

		<view v-if="!user_info.idCard" class="pf" style="bottom: 20rpx;width: 100%;">
			<view class="true-name" @tap="to_check" :style="{'background': isFilled()?'':'#C8C8C8'}">
				进行实名认证
			</view>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				card_name: '',
				card_id: '',
				phoneNum: "",
				code: "",
				time: "获取验证码",
				currentTime: 60,
			}
		},
		methods: {
			open() {
				// this.$refs.fixRef.open()
			},
			close() {
				this.$store.dispatch('refresh_user');
			},
			isFilled() {
				if (this.card_name.trim() && this.card_id.trim() && this.phoneNum.trim() && this.code.trim()) {
					return true
				}
				return false
			},
			to_check() {
				// if (String(this.phoneNum).trim() == '' || String(this.phoneNum).length != 11) {
				// 	this.showToast('请正确填写手机号码');
				// 	return;
				// }
				this.close();
				if (this.card_name.trim() == "") {
					this.showToast("请填写姓名");
					return;
				}
				if (this.card_id.trim() == "" || String(this.card_id).length != 18) {
					this.showToast("请正确填写身份证号");
					return;
				}
				// if (this.code.trim() == "" || String(this.code).length != 6) {
				// 	this.showToast("请正确填写验证码");
				// 	return;
				// }
				this.request({
					url: "/user/realName",
					method: "POST",
					data: {
						idCard: this.card_id,
						fullName: this.card_name,
						code: this.code,
					},
					loading: true,
				}).then((res) => {
					if (res.status == 200) {
						this.showToast("认证成功");
						this.$store.dispatch("refresh_user");
						this.close();
					}
				});
			},
			// sendRegistCode(e) {
			// 	if (this.time != "获取验证码") {
			// 		this.showToast("请稍等");
			// 		return;
			// 	}

			// 	this.less(() => {
			// 		let that = this;
			// 		console.log(that.phoneNum, "111");
			// 		var reg = /^1[3456789]\d{9}$/; //11位手机号码正则
			// 		if (that.phoneNum.length == 0) {
			// 			uni.showToast({
			// 				title: "请输入手机号",
			// 				icon: "none",
			// 			});
			// 		} else if (reg.test(that.phoneNum) == true) {
			// 			//   let currentTime = that.currentTime;
			// 			let interval;
			// 			this.request({
			// 				url: "/user/getUpdateCode",
			// 				data: {
			// 					phone: this.phoneNum,
			// 					uuid: this.uuid,
			// 					code: this.imgcode,
			// 				},
			// 				loading: true,
			// 			}).then((res) => {
			// 				if (res.status == 200) {
			// 					this.showToast("验证码已发送", 3000);
			// 					that.time = that.currentTime + "s后重新获取";
			// 					that.disabled = true;
			// 					interval = setInterval(function() {
			// 						that.time = that.currentTime - 1 + "s后重新获取";
			// 						that.currentTime--;
			// 						if (that.currentTime <= 0) {
			// 							clearInterval(interval);
			// 							(that.time = "获取验证码"),
			// 							(that.currentTime = 60),
			// 							(that.disabled = false);
			// 						}
			// 					}, 1000);
			// 					// this.to_check()
			// 				}
			// 			});
			// 		} else {
			// 			uni.showToast({
			// 				title: "请输入正确的手机号",
			// 				icon: "none",
			// 			});
			// 		}
			// 	});
			// },
		},
		onLoad(e) {
			// if (e.open) {
			// 	setTimeout(() => {
			// 		this.open();
			// 	}, 300);
			// }
		},
	}
</script>

<style lang="scss" scoped>

	page {
		background: #fff;
		font-size: 26rpx;
	}

	.maked-word {
		height: 60rpx;
		background: #DDF4BB;
		color: #78A23B;
	}

	.true-name {
		width: 80%;
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		color: #ffffff;
		background: linear-gradient(to right, #F02727, #F6A266);
		border-radius: 40rpx;
		margin: 20rpx auto;
	}
</style>